package com.openbravo.pos.panels.model;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import com.openbravo.bean.PaymentsLine;
import com.openbravo.pos.base.AppLocal;

public class PaymentsTableModel  extends AbstractTableModel{
	 private final static String[] SALEHEADERS = {"label.paymentstitle", "label.totalcash"};
	 List<PaymentsLine> m_lpayments;
	 
	 public PaymentsTableModel(List<PaymentsLine> m_lpayments) {
		this.m_lpayments =m_lpayments==null?new ArrayList():m_lpayments;
		
	}
	 
	public String getColumnName(int column) {
        return AppLocal.getIntString(SALEHEADERS[column]);
    }
    
	public int getRowCount() {
        return m_lpayments.size();
    }
	 
    public int getColumnCount() {
        return SALEHEADERS.length;
    }
    
    public Object getValueAt(int row, int column) {
        PaymentsLine l = m_lpayments.get(row);
        switch (column) {
        case 0: return l.getType();
        case 1: return l.getValue();
        default: return null;
        }
    }  
}